#include "klistview.h"
#include <QDebug>
namespace kdk {

class KListViewPrivate :public QObject
{
    Q_OBJECT
    Q_DECLARE_PUBLIC(KListView)
public:
    KListViewPrivate(KListView* parent);

private:
    KListView* q_ptr;
};


KListViewPrivate::KListViewPrivate(KListView *parent)
    :q_ptr(parent)
{
    Q_Q(KListView);
    setParent(parent);
}


KListView::KListView(QWidget *parent)
    :QListView(parent)
    ,d_ptr(new KListViewPrivate(this))
{
    Q_D(KListView);
}

void KListView::mousePressEvent(QMouseEvent *event)
{
    Q_D(KListView);
    QPoint p = event->pos(); //获取点击坐标
    QModelIndex index = indexAt(p); //点击位置是否为空
    if(!index.isValid())
    {
        setCurrentIndex(QModelIndex());     //实现点空白处取消选择
    }
    QListView::mousePressEvent(event);
}

}

#include "klistview.moc"
#include "moc_klistview.cpp"

